/**
 * Created by Lori on 2015/7/6.
 */
define(function(){
    var oblist = function(project, extTBName){
        this.project = project;
        this.boundData = new BoundData("oblist"	+ $E.staff.epidSql + (extTBName||''));
        this.boundData.KeyInfoEdit("oblist_guid");
        this.boundData.setCreateInfo("CREATEDDATE", "CREATEDBY", $E.staff.id);
        this.boundData.setModifyInfo("MODIFIEDDATE", "MODIFIEDBY", $E.staff.id);
    };

    oblist.prototype = {
        loadData : function(oblistGuid){
            //select oblist_guid,objective_guid,objectivetype_id,expectstarttime,expectendtime,lastcalltime,obstatus,attempt,max_attempt,failure_attempt,customer_guid from oblist{C1} where oblist_guid=@{C2}S
            var ret = this.project.commonQuerySync("ECore.Outbound.queryOblistByGuid", [$E.staff.epidSql, oblistGuid]);
            if(!$F.isNull(ret) && ret.value[0].count > 0) {
                this.boundData.NewValueEdit("oblist_guid", ret.value[0].fields[0][0]);
                this.boundData.NewValueEdit("objective_guid", ret.value[0].fields[0][1]);
                this.boundData.NewValueEdit("objectivetype_id", ret.value[0].fields[0][2]);

                this.boundData.NewValueEdit("expectstarttime", ret.value[0].fields[0][3], $CONST.BoundType.F_Date);
                this.boundData.NewValueEdit("expectendtime", ret.value[0].fields[0][4], $CONST.BoundType.F_Date);
                this.boundData.NewValueEdit("lastcalltime", ret.value[0].fields[0][5], $CONST.BoundType.F_Date);
                this.boundData.NewValueEdit("obstatus", ret.value[0].fields[0][6]);

                this.boundData.NewValueEdit("attempt", ret.value[0].fields[0][7], $CONST.BoundType.F_Int);
                this.boundData.NewValueEdit("max_attempt", ret.value[0].fields[0][8], $CONST.BoundType.F_Int);
                this.boundData.NewValueEdit("failure_attempt", ret.value[0].fields[0][9], $CONST.BoundType.F_Int);
                this.boundData.NewValueEdit("customer_guid", ret.value[0].fields[0][10]);
            }
        },

        getValue : function(fieldName){
            return this.boundData.getValue(fieldName);
        },

        setValue : function(fieldName, fieldValue){
            this.boundData.NewValueEdit(fieldName, fieldValue);
        }
    };

    return oblist;
});